package mychi

import "net/http"

func NewRouter() *Mux {
	return NewMux()
}

type Router interface {
	http.Handler
	Routes

	Use(middlewares ...func(http.Handler) http.Handler)

	With(middlewares ...func(http.Handler) http.Handler) Router

	Group(in func(r Router)) Router

	Route(pattern string, fn func(r Router)) Router

	Mount(pattern string, h http.Handler)

	Handle(pattern string, h http.Handler)
	HandleFunc(pattern string, h http.HandlerFunc)

	Method(method, pattern string, h http.Handler)
	MethodFunc(method, pattern string, h http.HandlerFunc)

	Connect(pattern string, h http.HandlerFunc)
	Delete(pattern string, h http.HandlerFunc)
	Get(pattern string, h http.HandlerFunc)
	Head(pattern string, h http.HandlerFunc)
	Options(pattern string, h http.HandlerFunc)
	Patch(pattern string, h http.HandlerFunc)
	Post(pattern string, h http.HandlerFunc)
	Put(pattern string, h http.HandlerFunc)
	Trace(pattern string, h http.HandlerFunc)

	NotFound(h http.HandlerFunc)

	MethodNotAllowed(h http.HandlerFunc)
}

type Routes interface {
	Routes() []Route
	Middlewares() Middlewares
	Match(ctx *Context, method, path string) bool
	Find(ctx *Context, method, path string) string
}

type Route struct {
	SubRoutes Routes
	Handlers  map[string]http.Handler
	Pattern   string
}

type Middlewares []func(http.Handler) http.Handler
